﻿package  {
	import flashx.textLayout.operations.ModifyInlineGraphicOperation;
	import flash.display.MovieClip;
	
	public class Monster extends MovieClip{
		public static const HAUT:Number = 0;
		public static const DROITE:Number = 1;
		public static const BAS:Number = 2;
		public static const GAUCHE:Number = 3;
		
		protected var m_HP:Number;
		protected var m_AttackDamage:Number;
		protected var m_SpeedMovement:Number;
		protected var m_Id:Number;
		
		public function Monster() {
			this.setHp(10);
			this.setAttackDamage(0);
		}
		
		public function setId(p_Id:Number):void
		{
			this.m_Id = p_Id;
		}
		
		public function getId():Number
		{
			return this.m_Id;
		}
		
		public function setHp(p_Hp:Number):void
		{
			this.m_HP = p_Hp;
		}
		
		public function getHp():Number
		{
			return this.m_HP;
		}
		
		protected function setAttackDamage(p_Dmg:Number):void
		{
			this.m_AttackDamage = p_Dmg;
		}
		
		public function getDamage():Number
		{
			return this.m_AttackDamage;
		}
		
		public function setSpeed(p_Speed:Number):void
		{
			this.m_SpeedMovement = p_Speed;
		}
		
		public function getSpeed():Number
		{
			return this.m_SpeedMovement;
		}
		
		public function receiveDamage(p_Damage:Number):void
		{
			if (this.getHp()-p_Damage > 0)
				this.setHp(this.getHp()-p_Damage);
			else
				this.setHp(0);
			
		}
		
		public function isDead():Boolean
		{
			return (this.getHp() == 0);
		}
		
		public function move(dir:Number):void
		{
			switch (dir)
			{
				case Monster.HAUT :
				{
					if (this.y - this.getSpeed()>= 0)
						this.y -= this.getSpeed();
					break;
				}
				case Monster.DROITE :
				{
					if(this.x + this.width + this.getSpeed() <= stage.width)
						this.x += this.getSpeed();
					break;
				}
				case Monster.BAS :
				{
					if (this.y + this.getSpeed() <= stage.height)
						this.y+= this.getSpeed();
					break;
				}
				case Monster.GAUCHE :
				{
					if(this.x - this.getSpeed() >= 0)
						this.x -= this.getSpeed();
					break;
				}
			}
		}
	}
	
}
